package com.iot.common.enums;

public enum ProductGoodType {
    GOOD_TYPE(0, "良品"),
    DEFECTIVE(1, "不良品"),
    ;

    private final int number;
    private final String character;

    ProductGoodType(int number, String character) {
        this.number = number;
        this.character = character;
    }

    public int getNumber() {
        return number;
    }

    public String getCharacter() {
        return character;
    }

    // 通过数字获取对应的枚举
    public static ProductGoodType fromNumber(int number) {
        for (ProductGoodType nce : ProductGoodType.values()) {
            if (nce.getNumber() == number) {
                return nce;
            }
        }
        throw new IllegalArgumentException("未知的数字: " + number);
    }
}

